<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/defaultconf.mex");
if (isset($_GET['get'])) {
    $mime = substr($_GET['get'], strlen($_GET['get']) - 3, strlen($_GET['get']));
    if ($mime == 'css') {
        header('mime-type:text/css');
        $ctype = 'text/css';
        $Type = 'CSS';
    } elseif ($mime == '.js') {
        header('mime-type:text/javascript');
        $ctype = 'text/javascript';
        $Type = 'JavaScript';
    } elseif ($mime == 'jpg') {
        header('mime-type:image/jpg');
        $ctype = 'image/jpg';
        header("Content-Transfer-Encoding: binary");
        $Type = 'Graphics';
    } elseif ($mime == 'gif') {
        header('mime-type:image/gif');
        $ctype = 'image/gif';
        header("Content-Transfer-Encoding: binary");
        $Type = 'Graphics';
    } elseif ($mime == 'png') {
        header('mime-type:image/png');
        $ctype = 'image/png';
        header("Content-Transfer-Encoding: binary");
        $Type = 'Graphics';
    } elseif ($mime == 'bmp') {
        header('mime-type:image/bmp');
        $ctype = 'image/bmp';
        header("Content-Transfer-Encoding: binary");
        $Type = 'Graphics';
    }
    header("Content-Type: $ctype");
    if (isset($_GET['Parent'])) {
        $Type = $_GET['Parent'];
    }
    $text = file_get_contents('../../../Shared/' . $Type . '/' . $_GET['get']);
    echo str_replace('url(../../', 'url(bin.php?Parent=' . $Type . '&get=', $text);
} elseif (isset($_GET['img'])) {
    $GETFILE = strtolower(str_replace('/', '', $_GET['img']));
    $PRXFILE = $GLOBALS['DOC'] . 'PRFLDOCS/' . $_GET['RSIF'] . '/' . $GETFILE;
    if (file_exists($PRXFILE) && is_readable($PRXFILE)) {
        $ext = explode(".", $PRXFILE);
        $extc = count($ext) - 1;
        $ext = $ext[$extc];

        switch ($ext) {
            case 'jpg':
                $mime = 'image/jpeg';
                break;
            case 'jpeg':
                $mime = 'image/jpeg';
                break;
            case 'gif':
                $mime = 'image/gif';
                break;
            case 'png':
                $mime = 'image/png';
                break;
            case 'bmp':
                $mime = 'image/bmp';
                break;
            case 'pdf':
                $mime = 'application/pdf';
                break;
            default:
                $mime = false;
        }

        if ($mime) {
            header('Content-type: ' . $mime);
            header('Content-length: ' . filesize($PRXFILE));
            echo file_get_contents($PRXFILE);
            exit;
        }
    }
}
?>
